package com.syyo.gulimall.auth;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;


/**
 * spring-session的原理
 * 1.导入@EnableRedisHttpSession 导入 RedisHttpSessionConfiguration配置
 *		1）给容器添加一个组件
 *			SessionRepository =>> RedisOperationsSessionRepository：redis操作session，session的增删改查类
 *		2）SessionRepositoryFilter==Filter：session存储过滤器，每个请求过来都会经过Filter
 *			1.创建的时候，就自动从容器中获取到了SessionRepository
 *			2.原生的request和response包装了SessionRepositoryRequestWrapper，SessionRepositoryResponseWrapper
 *			3.以后获取session，都是调用 wrappedRequest.getSession(),是从SessionRepository获取到的session
 *
 *	装饰者模式
 *
 *   		protected void doFilterInternal(HttpServletRequest request,
 *   								HttpServletResponse response,
 *   								FilterChain filterChain) throws ServletException, IOException {
 *         request.setAttribute(SESSION_REPOSITORY_ATTR, this.sessionRepository);
 *         SessionRepositoryFilter<S>.SessionRepositoryRequestWrapper wrappedRequest = new SessionRepositoryFilter.SessionRepositoryRequestWrapper(request, response, this.servletContext);
 *         SessionRepositoryFilter.SessionRepositoryResponseWrapper wrappedResponse = new SessionRepositoryFilter.SessionRepositoryResponseWrapper(wrappedRequest, response);
 *
 *         try {
 *             filterChain.doFilter(wrappedRequest, wrappedResponse);
 *         } finally {
 *             wrappedRequest.commitSession();
 *         }
 *
 *         自动延期
 *
 *
 */
@EnableRedisHttpSession // 整合redis作为session存储
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public class GulimallAuthApplication {

	public static void main(String[] args) {
		SpringApplication.run(GulimallAuthApplication.class, args);

		System.out.println(
				"       启动成功                   \n" +
						"    '----'        ||      //      \n" +
						"  //      \\\\      ||    //        \n" +
						" ||        ||     ||   //         \n" +
						" ||        ||     ||   \\\\         \n" +
						"  \\\\      //      ||    \\\\        \n" +
						"    '----'        ||      \\\\      ");
	}

}
